home *** CD-ROM | disk | FTP | other *** search
- /*==================================================================
- File: Win32ZStringExtractTool.cpp
-
- Contains: Tool for extracting ZString information from
- a binary on Windows
-
- Written by: Nalini Prakash
- Hayley Iben
-
- Copyright: 2000-2001 Connectix Corporation
-
- This source has been placed into the public domain by
- Connectix Corporation. You have the right to modify,
- distribute or use this code without any legal limitations
- or finanicial/licensing requirements. Connectix is not
- liable for any problems that result from the use of this
- code.
-
- If you have comments, feedback, questions, or would like
- to submit bug fixes or updates to this code, please email
- opensource@connectix.com.
- ==================================================================*/
-
- #include "StdAfx.h"
- #include "ZStringTool.h"
-
- #include "Win32ZString.h"
- #include "Win32ZStringTools.h"
- #include "Win32ZStringExtractTool.h"
-
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
-
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
-
- Win32ZStringExtractTool::Win32ZStringExtractTool()
- : mNewFile(INVALID_HANDLE_VALUE),
- mNewMemFile(0),
- mNewBinaryImage(0)
- {
- }
-
- Win32ZStringExtractTool::~Win32ZStringExtractTool()
- {
- // CleanUp.
- if (mNewFile != INVALID_HANDLE_VALUE)
- ::CloseFiles(mNewBinaryImage, mNewMemFile, mNewFile);
- }
-
-
- /*------------------------------------------------------------------
- ExtractZStrings
- ------------------------------------------------------------------*/
-
- bool
- Win32ZStringExtractTool::ExtractZStrings(
- CString inSrcFile,
- CString inDestFile,
- ZToolOptions inOptions)
- {
- Z_UInt32 newBinarySize;
-
- // Open as a memory mapped file.
- if (!::OpenMemMappedFile(inSrcFile, mNewFile, mNewMemFile,
- mNewBinaryImage, newBinarySize))
- {
- ::AfxMessageBox("Unable to open the source file.\n Extraction will not be completed.");
- return false;
- }
- // Open report file.
- FILE * reportFile = fopen(inDestFile, "w+");
- if (reportFile == NULL)
- {
- ::AfxMessageBox("Unable to open the destination file.\n Extraction will not be completed.");
- return false;
- }
-
- CWaitCursor cursor;
-
- // Process the data.
- ZStringTool stringTool;
- stringTool.ProcessBinaries(mNewBinaryImage, newBinarySize, NULL, 0, inOptions);
- stringTool.PrintReport(reportFile, inOptions);
-
- if (mNewFile != INVALID_HANDLE_VALUE)
- ::CloseFiles(mNewBinaryImage, mNewMemFile, mNewFile);
- fclose(reportFile);
- ::AfxMessageBox("Extraction report printed successfully.");
- return true;
- }
-
-
-